#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QTimer>
#include "BarTest.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

//    m_pMvpPanel = new CMvpPanel(this);
//    m_pMvpPanel->setGeometry(500,200,44,44);
//    m_pMvpPanel->show();

//    m_timerAni.setInterval(10000);
//    m_timerAni.setSingleShot(true);

//    connect(&m_timerAni, &QTimer::timeout, [this]() {
//        qDebug()<<"hello,ggggg";
//    });

//     m_timerAni.start();

//     m_lbLeftWinStreakCount = new QLabel(this);
//     m_lbLeftWinStreakCount->setGeometry(100,100,64,18);
//     m_lbLeftWinStreakCount->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
//     m_lbLeftWinStreakCount->setStyleSheet("font-size:10px;border-image:url(:/left_winsteak.png);color:white;padding:0 0 0 3;");
//     m_lbLeftWinStreakCount->setText("win x22415");

//     m_lbRightWinStreakCount = new QLabel(this);
//     m_lbRightWinStreakCount->setGeometry(300,100,64,18);
//     m_lbRightWinStreakCount->setMargin(0);
//     m_lbRightWinStreakCount->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
//     m_lbRightWinStreakCount->setStyleSheet("font-size:10px;border-image:url(:/right_winsteak.png);color:white;padding:0 3 0 0;");
//     m_lbRightWinStreakCount->setText("win x88781");

    BarTest* bar = new BarTest(this);
    bar->setGeometry(0,100,40,40);
    bar->setFixedSize(40,40);
    bar->show();
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    static int i = 0;
    i++;
    if(i%5 == 0)
        m_pMvpPanel->UpdateText(QString::number(9),true);
    else if(i%5 == 1)
        m_pMvpPanel->UpdateText(QString::number(99),true);
    else if(i%5 == 2)
        m_pMvpPanel->UpdateText(QString::number(999),true);
    else if(i%5 == 3)
        m_pMvpPanel->UpdateText(QString::number(9999),true);
    else if(i%5 == 4)
        m_pMvpPanel->UpdateText(QString::number(99999),true);


}

void Widget::on_pushButton_2_clicked()
{
    m_pMvpPanel->UpdateText("hello,world");
}

void Widget::on_pushButton_3_clicked()
{
    static int i = 0;
    i++;
    if(i%2==0)
        m_pMvpPanel->UpdateHeadBorder(":/kl_icon_mvp_trophy_get.png");
    else
        m_pMvpPanel->UpdateHeadBorder(":/kl_icon_mvp_trophy_get_not.png");
}

void Widget::on_pushButton_4_clicked()
{
//    if(m_timerAni.isActive()){
//        m_timerAni.stop();
//        disconnect(&m_timerAni,0,0,0);
//    }

//    m_timerAni.setInterval(3000);
//    m_timerAni.setSingleShot(false);
//    connect(&m_timerAni, &QTimer::timeout, [=]() {
//        static int i = 0;
//        i++;
//        if(i%2==0)
//        {
//            ui->label_2->hide();
//            m_pMvpPanel->show();
//        }else
//        {
//            ui->label_2->show();
//            m_pMvpPanel->hide();
//        }
//    });
//    m_timerAni.start();

    QPropertyAnimation *animation = new QPropertyAnimation(ui->label, "geometry");
    animation->setDuration(5000);
    animation->setStartValue(QRect(0, 300, 100, 30));
    animation->setEndValue(QRect(1000, 300, 100, 30));

    animation->start();

    QPropertyAnimation *animation2 = new QPropertyAnimation(ui->label_2, "geometry");
    animation2->setDuration(5000);
    animation2->setStartValue(QRect(150, 300, 100, 30));
    animation2->setEndValue(QRect(1150, 300, 100, 30));

    animation2->start();
}
